<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>活动申请结果查询</title>
    <link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
</head>
<body>

<table id="demo" lay-filter="test"></table>

<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script>
    layui.use(['table', 'layer','jquery'], function () {
        var table = layui.table;
        var layer = layui.layer;
        let $ = layui.jquery;
        table.render({
            elem: '#demo',
            height: 'auto',
            url: '/activity/getActivityResult', //数据接口,
            page: true, //开启分页
            cols: [[ //表头
                {field: 'actApplyResultId', title: '活动申请认定编号', width: "13%"},
                {field: 'actApplyId', title: '活动申请编号', width: "10%"},
                {field: 'approveOrnot', title: '通过与否', width: "10%",templet:function (data) {
                        if (data.approveOrnot==='1'){
                            // 通过
                            return '已通过';
                        }else if (!data.approveOrnot){
                            return '待处理';
                        }else if (data.approveOrnot==='2'){
                            return '拒绝';
                        }
                    }},
                {field: 'teacherId', title: '教师工号', width: "10%"},
                {field: 'teacherName', title: '教师姓名', width: "10%"},
                {field: 'teacherDepart', title: '教师部门', width: "10%"},
                {field: 'applyresultsDate', title: '回应日期', width: "10%"},
            ]],
            response: {
                statusCode: 200,//规定成功的状态码，默认：0
            }
        });
        table.on('tool(test)', function(obj){
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
            if(layEvent === 'apply') { //申请
                layer.msg("同意");
            }else if (layEvent==='refuse'){
                layer.msg("拒绝");
            }
        })

    })
</script>
</body>
</html>